from apps.goods.models import GoodsChannel, GoodsChannelGroup, GoodsCategory
from apps.meiduo_admin.serializers.channels import ChannelSerializer, ChannelsSimpleSerializer
from apps.meiduo_admin.utils.pagination import MeiduoPagination
from rest_framework.generics import ListAPIView
from rest_framework.viewsets import ModelViewSet
from apps.meiduo_admin.serializers.channels import ChannelsCategorySerializer


class ChannelsView(ModelViewSet):
    queryset = GoodsChannel.objects.all().order_by('-id')
    serializer_class = ChannelSerializer
    pagination_class = MeiduoPagination


class ChannelsSimpleView(ListAPIView):
    queryset = GoodsChannelGroup.objects.all()
    serializer_class = ChannelsSimpleSerializer


class ChannelsCategoryView(ListAPIView):
    queryset = GoodsCategory.objects.filter(parent__isnull=True)
    serializer_class = ChannelsCategorySerializer
